package com.dferreira.languagesteach.activities.generic;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.dferreira.languagesteach.LanguagesTeachApplication;
import com.dferreira.languagesteach.helpers.GenericUI;
import com.dferreira.languagesteach.utils.ApplicationState;

public abstract class ExercisesActivity extends Activity {


    /**
     * Called when the activity is starting.  This is where most initialization
     *
     * @param savedInstanceState If the activity is being re-initialized after
     *                           previously being shut down then this Bundle contains the data it most
     *                           recently supplied in {@link #onSaveInstanceState}.  <b><i>Note: Otherwise it is null.</i></b>
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    /**
     * @param menu a reference to the menu
     * @return always will be true
     */
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return GenericUI.onCreateOptionsMenu(this, menu);
    }

    /**
     * This hook is called whenever an item in your options menu is selected.
     *
     * @param item which was selected
     * @return always will return false
     */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        GenericUI.onOptionsItemSelected(this, item);
        return super.onOptionsItemSelected(item);
    }

    /**
     * Called as part of the activity lifecycle when an activity is going into
     * the background, but has not (yet) been killed.  The counterpart to
     * {@link #onResume}.
     */
    @Override
    public void onPause() {
        String activityClassName;
        ApplicationState applicationState;
        super.onPause();

        applicationState = LanguagesTeachApplication.getApplicationState();
        activityClassName = this.getClass().getName();
        applicationState.setCurrentClassController(activityClassName);
        LanguagesTeachApplication.saveSubjectPath();

    }
}
